Skip to content

Instantly share code, notes, and snippets.

@atheiman
atheiman / aws_switch_role_bookmark_generator.py
Last active May 21, 2024 11:59
AWS organization switch role (assume role) bookmark generator - outputs html to stdout that can be saved to a .html file and imported into browser bookmarks.
import boto3
import os
# Environment variables for configuration
role_name = os.environ.get("ROLE_NAME", "OrganizationAccountAccessRole")
include_mgmt = os.environ.get("INCLUDE_MGMT", "true").lower() == "true"
sts = boto3.client("sts")
caller_arn = sts.get_caller_identity()["Arn"]
partition = caller_arn.split(":")[1]
@atheiman
atheiman / docker-image-share.sh
Created May 21, 2024 01:55
Package and share docker image
# Package docker image to .tar.gz to share to another machine
docker pull alpine
docker save alpine | gzip > alpine.tar.gz
# Load docker image from .tar.gz
docker load < alpine.tar.gz
# Show loaded image
docker image ls alpine
# REPOSITORY TAG IMAGE ID CREATED SIZE
@Sirpyerre
Sirpyerre / Dockerfile
Last active May 21, 2024 11:58
Dockerfile Laravel SQL SERVER
FROM ubuntu:21.10
LABEL maintainer="Taylor Otwell"
ARG WWWGROUP
WORKDIR /var/www/html
ENV DEBIAN_FRONTEND noninteractive
ENV TZ=UTC
@serif
serif / bwclean2.py
Last active May 21, 2024 11:57
Bitwarden Duplicate Entry Remover v2
#!/usr/bin/env python3
# updated 2023-11-27
# updated 2023-10-12
# updated 2021
# updated 2020
# created 2018
import sys
import hashlib
from urllib.parse import urlparse
<?php
use PhpOffice\PhpSpreadsheet\IOFactory;
use PhpOffice\PhpSpreadsheet\Spreadsheet;
use PhpOffice\PhpSpreadsheet\Style\Border;
use PhpOffice\PhpSpreadsheet\Style\Color;
//создать лист и задать отступы
$oSpreadsheet = new Spreadsheet();
$sheet = $oSpreadsheet->getActiveSheet();
$sheet->getPageMargins()
@roib20
roib20 / apt-repo-playbook.yaml
Last active May 21, 2024 11:55
Example usages of the new `deb822_repository` Ansible module
---
- hosts: localhost
connection: local
gather_facts: true
tasks:
- name: Add APT repositories
when: ansible_os_family == 'Debian'
become: true
block:
@freak4pc
freak4pc / IsraeliID.Validator.js
Last active May 21, 2024 11:53
Israeli ID Validator (Javascript)
function isValidIsraeliID(id) {
var id = String(id).trim();
if (id.length > 9 || id.length < 5 || isNaN(id)) return false;
// Pad string with zeros up to 9 digits
id = id.length < 9 ? ("00000000" + id).slice(-9) : id;
return Array
.from(id, Number)
.reduce((counter, digit, i) => {
@tordans
tordans / application_helper.rb
Created September 27, 2010 12:47
Eine pragmatische Lösung für das Übersetzungsproblem der Rails Methode distance_of_time_in_words(). Im Deutschen wird je nach Satzbau eine andere Ausgabe benötigt.
# ---
# Code gehört in app/helpers/application_helper.rb (oder einen anderen Helper…)
# ---
# Ausgabe: "Vor mehr als 5 Monaten"/"Vor etwa einem Jahr" — statt "Dauer: mehr als 5 Monate"/"Dauer: etwa 1 Jahr", wie es die Originalfunktion liefert
# Original-File: actionpack/lib/action_view/helpers/date_helper.rb, line 63
# Dokumenation: http://apidock.com/rails/v2.3.8/ActionView/Helpers/DateHelper/distance_of_time_in_words
# Changelog: I18n.with_options-Scope geändert auf "distance_in_words_gebeugt"
def distance_of_time_in_words_gebeugt(from_time, to_time = 0, include_seconds = false, options = {})
from_time = from_time.to_time if from_time.respond_to?(:to_time)
@rahularity
rahularity / work-with-multiple-github-accounts.md
Last active May 21, 2024 11:52
How To Work With Multiple Github Accounts on your PC

How To Work With Multiple Github Accounts on a single Machine

Let suppose I have two github accounts, https://github.com/rahul-office and https://github.com/rahul-personal. Now i want to setup my mac to easily talk to both the github accounts.

NOTE: This logic can be extended to more than two accounts also. :)

The setup can be done in 5 easy steps:

Steps:

  • Step 1 : Create SSH keys for all accounts
  • Step 2 : Add SSH keys to SSH Agent
@Klerith
Klerith / seed.ts
Created July 12, 2022 18:55
Nest-Teslo Seed
interface SeedProduct {
description: string;
images: string[];
stock: number;
price: number;
sizes: ValidSizes[];
slug: string;
tags: string[];
title: string;
type: ValidTypes;